package com.wxw.BaseLibrary.tool;

import android.content.Context;
import android.database.ContentObserver;
import android.os.Handler;
import com.wxw.BaseLibrary.element.Sms;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by david on 2016-01-04.
 */
public class SmsObserver extends ContentObserver {
    private Context con = null;
    private SmsTool smsTool = null;
    private List<Sms> smsList = new ArrayList<Sms>();

    public SmsObserver(Context context, Handler handler) {
        super(handler);
        con = context;
        smsTool = new SmsTool(context);
    }

    public SmsTool getSmsTool() {
        return smsTool;
    }

    public List<Sms> getSmsList() {
        return smsList;
    }

    @Override
    public void onChange(boolean selfChange) {
        super.onChange(selfChange);
        smsList.clear();
        if (smsTool!=null) {
            smsList = smsTool.getSmsFromPhone();
        }
    }
}
